package com.sghd.pojo.fight.game;

import com.fasterxml.jackson.annotation.JsonIgnore;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author frank
 * @date 2018-10-30 14:30
 * @desc
 **/
public class TargetReport {
    /** 技能目标*/
    private long target;
    /** 施放者*/
    private long source;
    /** 状态(预留字段)*/
    private int state;
    /** 数值变化*/
    //@JsonInclude(JsonInclude.Include.NON_NULL)
    private List<ValueItem> values = new ArrayList<>();
    /** buff变化*/
    //@JsonInclude(JsonInclude.Include.NON_NULL)
    private List<BuffReport> buffs = new ArrayList<>();
    /** 绝对值*/
    private List<ValueItem> abs = new ArrayList<>();
    /** 魔法值*/
    private Map<ChessType, Integer> magics = new HashMap<>();

    public TargetReport(long target, long source) {
        this.target = target;
        this.source = source;
    }

    public TargetReport() {
    }

    public void addValue(ValueItem value) {
        values.add(value);
    }

    public void addBuff(BuffReport buffReport) {
        buffs.add(buffReport);
    }

    public long getTarget() {
        return target;
    }

    public void setTarget(long target) {
        this.target = target;
    }

    public long getSource() {
        return source;
    }

    public void setSource(long source) {
        this.source = source;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public List<ValueItem> getValues() {
        return values;
    }

    public void setValues(List<ValueItem> values) {
        this.values = values;
    }

    public List<BuffReport> getBuffs() {
        return buffs;
    }

    public void setBuffs(List<BuffReport> buffs) {
        this.buffs = buffs;
    }

    public List<ValueItem> getAbs() {
        return abs;
    }

    public void setAbs(List<ValueItem> abs) {
        this.abs = abs;
    }

    public Map<ChessType, Integer> getMagics() {
        return magics;
    }

    public void setMagics(Map<ChessType, Integer> magics) {
        this.magics = magics;
    }
    @JsonIgnore
    public void addStatus(int state) {
        if (hasStatus(state)) {
            return;
        }
        this.state |= state;
    }

    @JsonIgnore
    public boolean hasStatus(int state) {
        return (this.state & state) == state;
    }

    @JsonIgnore
    public void removeStatus(int state) {
        if (hasStatus(state)) {
            this.state ^= state;
        }
    }
}
